/*
 * Copyright (c) 2012 Tomas Shestakov. <http://code.google.com/p/jmmo/>
 */

package jmmo.engine.gameactor

import jmmo.engine.property._
import scala.Some

trait AlterationRequest extends Serializable {

  def alteration: Alteration

  def chain: Seq[Identifier]
}

object AlterationRequest {

  def unapplySeq(request: AlterationRequest): Option[(Alteration, Seq[Identifier])] =
    if (request eq null) None
    else Some(request.alteration, request.chain)
}

case class AlterationChangeRequest[A](alteration: ChangeAlteration[A], chain: Identifier*) extends AlterationRequest

case class AlterationCompareAndChangeRequest[A](expect: A, alteration: ChangeAlteration[A], chain: Identifier*) extends AlterationRequest

case class AlterationAddRequest(alteration: AddAlteration[Identifier], chain: Identifier*) extends AlterationRequest

case class AlterationRemoveRequest(alteration: RemoveAlteration[Identifier], chain: Identifier*) extends AlterationRequest

case class AlterationAddEntirelyRequest(alteration: AddAlteration[SerializedObservable], chain: Identifier*) extends AlterationRequest